using System;

namespace Jeffrey.XFramework.XInteract
{
    public delegate void SpdiersEventHandler<MessageType>(Object sender, MessageType mt);
    public delegate void XuthusEventHandler(Object sender, EventArgs e);

    public class ObservableXubject
    {
        public event SpdiersEventHandler<MessagePackage>      GeneralEvent        = null;
        public event SpdiersEventHandler<DownLoadingPackage>  DownLoading         = null;
        public event SpdiersEventHandler<SpiderStatusPackage> SpiderStatusChanged = null;
        public event SpdiersEventHandler<ErrorPackage>        ErrorOccurred       = null;

        public event XuthusEventHandler AllSpdiersStop = null;

        protected internal void OnAllSpidersStop()
        {
            if (AllSpdiersStop != null)
                AllSpdiersStop(this, new EventArgs());
        }

        protected internal void OnGeneralEvent(MessagePackage mp)
        {
            if (GeneralEvent != null)
                GeneralEvent(this, mp);
        }

        protected internal void OnSpiderStatusChanged(SpiderStatusPackage ssp)
        {
            if (SpiderStatusChanged != null)
                SpiderStatusChanged(this, ssp);
        }

        protected internal void OnDownLoading(DownLoadingPackage dlp)
        {
            if (DownLoading != null)
                DownLoading(this, dlp);
        }

        protected internal void OnErrorOccurred(ErrorPackage ep)
        {
            if (ErrorOccurred != null)
                ErrorOccurred(this, ep);
        }
    }

}
